<?php
class user_candoAction extends runAction {
	
	public function index() {
		if(empty($_GET['id'])){
			$this->assign('jUrl','/adminiii.php/user');
			$this->error('没有指定用户');
			exit;
		}
		
		if($_GET['id']==1){
			$this->assign('jUrl','/adminiii.php/user');
			$this->error('此用户不能更改权限');
			exit;
		}
		
		$o = M('user');
		$val = $o->find($_GET['id']);
		$this->assign('val',$val);
		
		$tmp = explode("\r\n",$val['cando']);
		$cando = implode("','",$tmp);
		$cando = "'".$cando."'";
		
		$this->assign('cando',$cando);
		
		$this->display ();
	}
	
	
	
	public function save() {
			
		$o = M ( 'user' );
		$cando = str_replace('|',"\r\n",$_POST['cando']);
		$data['cando'] = implode("\r\n",$cando);
		$st = $o->data($data)->where('id='.$_POST['id'])->save ();
		
		if ($st !== false) {
			
			$GLOBALS ['id'] = $_POST ['id'];

			$this->assign('jUrl','/adminiii.php/user');
			$this->success ( '修改成功' );
		} else {
			$this->assign('jUrl','/adminiii.php/user_cando/?id='.$_POST['id']);
			$this->error ( '修改失败' );
		}
	}
		
	
	
}
?>